<?
//20190602
//截取utf8字符串
//$str, $from, $len,$ellipsis
//$p['str'];//字符串
//$p['from'];//从哪里开始截取
//$p['len'];//截取多长

function utf8_substr($conditon)
{

    $content_01 = $conditon['str'];//从数据库获取富文本content
    $content_02 = htmlspecialchars_decode($content_01);//把一些预定义的 HTML 实体转换为字符
    $content_03 = str_replace("&nbsp;","",$content_02);//将空格替换成空
    $contents   = strip_tags($content_03);//函数剥去字符串中的 HTML、XML 以及 PHP 的标签,获取纯文本内容
    $result        = mb_substr($contents, $conditon['from'], $conditon['len'],"utf-8");//返回字符串中的前100字符串长度的字符


return $result;
}
?>